﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenExpressApp.Types;

namespace OpenExpressApp.MetaAttribute
{
    /// <summary>
    /// 查询对象所使用的Attribute
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public class QueryObjectAttribute : Attribute
    {
        public QueryObjectAttribute(Type objectType)
        {
            this.ObjectType = objectType;
            ViewType = ViewType.ListView;
        }

        public Type ObjectType { get; set; }

        public ViewType ViewType { get; set; }
        
        /// <summary>
        /// 不需要点击查询，自动调用GetList来装载数据
        /// </summary>
        public bool AutoLoadList { get; set; }
    }

    /// <summary>
    /// 对该类进行条件查询的条件
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class QueryPaneAttribute : Attribute
    {
        public QueryPaneAttribute(bool autoHide)
        {
            this.AutoHide = autoHide;
        }

        public bool AutoHide { get; set; }
    }

    /// <summary>
    /// 对该类进行条件查询的条件
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class CondtionQueryTypeAttribute : Attribute
    {
        public CondtionQueryTypeAttribute(Type queryType)
        {
            QueryType = queryType;
        }

        /// <summary>
        /// 条件查询的条件对象的类型
        /// </summary>
        public Type QueryType { get; private set; }
        /// <summary>
        /// 显示的Header
        /// </summary>
        public string Header { get; private set; }
    }

    /// <summary>
    /// 对该类进行导航查询的条件
    /// </summary>
    [AttributeUsage(AttributeTargets.Class)]
    public class NavigateQueryTypeAttribute : Attribute
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="type">导航查询的条件对象的类型</param>
        public NavigateQueryTypeAttribute(Type queryType)
        {
            QueryType = queryType;
            this.NavigateQueryRegionPosition = QueryRegionPosition.Alone;
            NavigateQueryMode = NavigateQueryMode.Remote;
        }

        public NavigateQueryMode NavigateQueryMode { get; set; }

        /// <summary>
        /// 导航查询的条件对象的类型
        /// </summary>
        public Type QueryType { get; private set; }
        /// <summary>
        /// 显示的Header
        /// </summary>
        public string Header { get; set; }
        public QueryRegionPosition NavigateQueryRegionPosition { get; set; }
    }


    /// <summary>
    /// 查询页签
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, Inherited = false)]
    public class QueryItemValueTypeAttribute : Attribute
    {
        public QueryItemValueTypeAttribute(QueryItemValueType queryItemValueType)
        {
            this.QueryItemValueType = queryItemValueType;
        }

        public QueryItemValueType QueryItemValueType { get; set; }
        public string IdPropertyName { get; set; }
    }

    [AttributeUsage(AttributeTargets.Property, Inherited = false)]
    public class NavigateQueryItemAttribute : Attribute { }
}